finp$="_memorama_spritesheet_.png"

' converts a 128x128 x2 4c picture into a 'pmode1:screen1,0' binary file - chr 4x8 mode

zoomx=2
fout1$=finp$+".zxb"
setdisplay(128,128,32,1):paper(8^8-1):ink(0):pen(0):cls
loadimage(finp$,1):pasteicon(0,0,1)

open fout1$ for output as #1

print #1,"asm"

for y1=0 to 15
  for x1=0 to 15
    txou1$="  defb "
    for y2=0 to 7
      y=(y1*8)+y2
      btv=0:btt=0
      for x2=3 to 0 step -1
        btv=btv*4
        x3=(x1*4+(3-x2))*zoomx
        u=point(x3,y)
        b=u mod 256: u=int(u/256)
        g=u mod 256: u=int(u/256)
        r=u mod 256: u=int(u/256)
        '- needs revision
        btt=3                                             '-o
        if (b>128 and r<128) then:btt=1:end if            '-c
        if (b>128 and r>128) and g<128 then:btt=2:end if  '-m
        if (b>128 and r>128) and g>128 then:btt=0:end if  '-w
        btv=btv+btt
        next
      txou1$=txou1$+"$"+ucase$(right$("00"+hex$(btv),2))+""
      if y2<7 then:txou1$=txou1$+",":end if
      next
    print #1,txou1$

    next
  next

print #1,"end asm"

close #1

'waitkey

